<template>
	<view class="page">
		<view class="top">
			<view class="toptit">充值金额</view>
			<view class="topcon">
				<view>
					<text>¥</text>
					<input type="text" v-model="jine" placeholder="输入金额" />
				</view>
				<view>元</view>
			</view>
		</view>
		
		<button class="queren" @tap="chongzhi">充值</button>
	</view>
</template>

<script>
		import { mapState } from 'vuex';
export default {
	data() {
		return {
			items: [
				{
					value: 'USA',
					name: '美国'
				},
				{
					value: 'CHN',
					name: '中国',
					checked: 'true'
				},
				{
					value: 'BRA',
					name: '巴西'
				},
				{
					value: 'JPN',
					name: '日本'
				},
				{
					value: 'ENG',
					name: '英国'
				},
				{
					value: 'FRA',
					name: '法国'
				}
			],
			current: 0,
			jine: '',
			type: ''
		};
	},
	computed: mapState({
		 userinfo: 'userinfo'
	}),
	methods: {
		radioChange: function(evt) {
			for (let i = 0; i < this.items.length; i++) {
				if (this.items[i].value === evt.target.value) {
					this.current = i;
					break;
				}
			}
		},
		chongzhi() {
			if(this.jine>0){
				var data = {
					token: uni.getStorageSync('token'),
					yh_id:this.userinfo.yh_id,
					rujin_jine:this.jine
				}
				// uni.navigateTo({
				// 	url:'../rujin/index'
				// })
				 this.$store
					.dispatch('recharge', data)
					.then(res => {
						if(res.data.code==1){
							var bank = res.data.data;
							
							uni.navigateTo({
								url:'../rujin/index?bank_bh=' + bank.bank_bh +  "&rujin_jine=" +bank.rujin_jine+  "&bank_id=" +bank.bank_id+  "&rujin_id=" +bank.rujin_id+ "&kh_xingming=" +bank.kh_xingming + "&bank_khh=" +bank.bank_khh+ "&bank_name=" +bank.bank_name  
							})
						}
						else{
							uni.showToast({
								title: res.data.msg,
								icon: 'none'
							});
						}
						
					})
				
			}
			else{
				uni.showToast({
					title: '请输入充值金额',
					icon: 'none'
				});
			}
			
		}
	}
};
</script>

<style lang="scss" scoped src="./index.scss"></style>
